package com.karry.commons;


import com.karry.commons.util.AESUtil;

import javax.sql.DataSource;
import java.util.Properties;

/**
 * 创建人：田轩
 * 创建时间：2017/11/8
 * 描述：
 */
public class DruidDataSourceFactory {

    public static DataSource createDataSource() {
        Properties druidConfig = new PropertiesHandler("druid").getProperties();
        DataSource dataSource = null;
        try {
            String password = druidConfig.getProperty("password");
            druidConfig.setProperty("password",AESUtil.decrypt(password,Constants.DB_AES_KEY));
            dataSource = com.alibaba.druid.pool.DruidDataSourceFactory.createDataSource(druidConfig);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataSource;
    }
}
